home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Especial Multimedia
/
Especial Multimedia.iso
/
Multimed
/
Prg
/
DEPAL.ZIP
/
SOURCE.ZIP
/
PED.BAS
< prev
next >
Wrap
BASIC Source File
|
1995-03-13
|
2KB
|
84 lines
Option Explicit
Global filename As String
Global Directory As String
Global Drivename As String
Global FilePath As String
Global Pathname As String
Global Success As Integer
'================ Dither236 ==========================
'
' this will dither an image to the middle 236 colors
' of a palette using the Floyd Steinberg algorithm
' with an error damping threshhold of 8
'
Sub Dither236 (ctl As control, ByVal palette As Integer)
Dim i As Integer
ReDim ignore(0 To 255) As Integer
For i = 0 To 9
ignore(i) = 2
Next i
For i = 246 To 255
ignore(i) = 2
Next i
Call Dither(ctl, ignore(), palette, 8)
Erase ignore
End Sub
Sub ReadPalette (Pal As control, filename As String)
Open filename For Input As #1
Dim i As Integer, inx As Integer
Dim red As Integer, green As Integer, blue As Integer
Dim Color As Long
While Not EOF(1)
Input #1, red, green, blue, inx
Pal.Cindex = inx
Pal.Color = RGB(red, green, blue)
Wend
Close #1
End Sub
'================= Remap236 ==========================
'
' this will remap an image to the middle 236 colors
' of a palette using closest color matching.
'
Sub Remap236 (ctl As control, ByVal palette As Integer)
Dim i As Integer
ReDim ignore(0 To 255) As Integer
For i = 0 To 9
ignore(i) = 2
Next i
For i = 246 To 255
ignore(i) = 2
Next i
Call Remap(ctl, ignore(), palette)
Erase ignore
End Sub
Sub WritePalette (Pal As control, filename As String)
Open filename For Output As #1
Dim i As Integer
Dim red As Integer, green As Integer, blue As Integer
Dim Color As Long
For i = 0 To 255
Pal.Cindex = i
Color = Pal.Color
Call GetRGB(Color, red, green, blue)
Print #1, red, green, blue, i
Next
Close #1
End Sub